package com.example.logindb.sevices;


import com.example.logindb.entity.Online;
import com.example.logindb.repository.OnlineRepository;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class OnlineServiceImpl implements OnlineService {
    private OnlineRepository onlineRepository;
    public OnlineServiceImpl(OnlineRepository onlineRepository)
    {
        this.onlineRepository = onlineRepository;
    }

    @Override
    public void updateStatus(Online online) {
        // 更新在线状态
        onlineRepository.save(online);
    }

    @Override
    public Online findStatusById(Integer id) {
        return onlineRepository.findStatusById(id);
    }

    //弃用
    @Override
    public Integer getOnlineCount() {
        return Math.toIntExact(onlineRepository.count());
    }
    //
    @Override
    public Integer getCountByStatus() {
        Integer online1 = onlineRepository.countByStatus(1);
        Integer online2 = onlineRepository.countByStatus(2);
        Integer online3 = onlineRepository.countByStatus(3);
        return online1 + online2 + online3;
    }


//    @Override
//    public List<String> findGeojsonByBlindID(int id) {
//        return routeRepository.findGeoJsonByBlindid(id);
//    }


}